/*
OPEN BUGS - ranked by priority

STILL some NaN BS going on somewhere...this is REALLY REALLY BAD and really sporadic, too - can't reproduce with any consistency.
Check every place that alters locations and involves a divide:
  Particle timeStep()
  SolidWall2d collideTest(), projectCollide(), reflectAndFriction() [which looks like it has a potential nasty divide by zero in it!] [THIS ONE FIXED, BUG LEFT OPEN IN CASE MORE SHOW UP!]

Build player location and goal location into parser - currently set to defaults in levelInitialize

Temp Vector3d creation is out of control - can't be creating 25000 temporary objects per frame!!! (the 50 temp particles is bad enough!)
Turns out it's the fault of the Box2d class using vectors and being dynamically created...let's cache the dynamic ones and fix this mess
[Mostly fixed - Box2d under control, now only ~1500 per frame with a lot of active particles, still not ideal, though]

Though wall-end check has been added, it's merely a simple location check, and still allows tunelling - do a bona fide crossing check here (circle crossing - shouldn't be too difficult)

Better than fixing above bug, rework line seg-circle collision code altogether
  Change methodology - first, check crossing against capped line (2 line segs, 2 semicircles) for collision, then do a projection out of the forbidden area to handle resting contact/slipthrough
  Generate list of crossings, find smallest TOI crossing and collide versus that one only  

The HTML/JS/Java interaction is weird, sometimes it doesn't properly initialize the level (probably ditch JS as level loader?).

Constructed items have edges that don't collide with walls - these are fine for ropes and stuff like that,
but we really need a true rigid body object.

Add better means of parsing; currently we use String.split(), but this has problems - need to implement a real parser eventually [minor issue if level design program is completed]

Clean up early-exit collision code - in LineAthlete we figured out how to do this the "right" way, use that since current method is neither optimal or robust

If a particle starts in a position where it collides with a wall, the particle and everything attached to it go kablooey, along with the simulation
Maybe perform a collision check first thing, and attempt to resolve it one way or another; alt, enforce at level design stage.

Clean up main draw() loop - it's really big, and really ugly

Rearrange functions/classes into appropriate tabs so that they are easier to find

Inconsistency in id labelling - Strut.id, SolidWall2d.idNum


OPTIMIZATIONS

~60 struts is causing speed problems, there MUST be a way to speed this up a little [Maybe fixed - some of this was temp object creation, some of it might be Mac Java weirdness]

Add specialized OpenGL drawing functions that don't go through the Processing graphics pipeline - these may be much faster

Speed up the getWalls/StrutsInRange functions, they are called per-particle so must be very optimized

Cache wall lengths/normal vectors/tangent vectors to avoid recomputing

Refactor binning, it's starting to get really difficult to add new kinds of objects here because of all the code duplication needed

Getting slowdowns when lots of FX particles are active, try to figure out a good way to mitigate this [partially done]

In tests, getting an object through a plain old array is 4x as fast as getting it through an ArrayList,
and since most of our accesses currently take place through ArrayLists, this is a major problem.
Possible solution: generate these things as ArrayLists during setup, but after generation, load them into normal
arrays for the draw() loop.  Unfortunately some will have to remain ArrayLists, because we don't know their sizes
during runtime

The initialization code is real messy, could likely be sped up with small effort if it becomes an issue (doesn't appear to be at this point)


ENHANCEMENTS

Design at least one sweet test level
Add activity recorder/playback
Add angular constraints (which will allow us to add sliding constraints with some more work)
Add moving walls and scripted walls/particles - probably easier once rigid bodies are here
Add pulleys and Worms-like ropes (i.e. if they hit a wall corner they bend around it) so that we don't need as many segments for ropes

[Hold off on Sprite stuff til after first release - maybe add in pogo-stick game to get working right]

Add collision detection to Sprite
Add pinning-to-particle/strut to Sprite
Add non-rectangular shapes to Sprite
Add rotation to Sprite
Add sprites to level format

Tune key control of rotation
Get the damn editor working so level design doesn't have to be done by hand
Add C-style slash star comments to level format


FIXED/DONE

Allow camera/rgb placement in level format [Done - also added other parameter setting]

Add some sort of gameplay goal [DONE - simple goal point added]

Inline temp-vector usage to avoid object creation - this is happening a LOT all over the place [Done]

Get graphics displaying correctly under OpenGL (Done - changed point drawing code if OpenGL mode is active)

STILL SOME OPEN DIVIDE BY ZERO BUGS - FIND EVERY ONE OF THESE OR ELSE!!!!! (Done [June 27, 2007] - turned out to be a zero vector attempted normalization issue)

Upgrade collision code - back-port LineAthlete code to take care of things like tunneling through corners
(need to add a point-sphere check at the line ends, since crossing doesn't happen - for now, forget about friction, just project away) (Done [May 17, 2007])

Added Sprite class with crude animation support

Some collision detections are still using naive unpartitioned pairwise checks.  FIX THIS FAST! (Done [May 6, 2007])

Spatial partitioning has some edge issues,like when the wall is exactly along a cell boundary.  Added
a quick fix by shifting min/max by EPSILON, but need to make sure this is robust (Done [May 7, 2007] - added Box2d.expand() )

Allow keyboard control of rotation (esp. for people with touchpads!) (Done [May 8, 2007] - left and right arrows now control)

[re: some crap in sim loop] this still checks against every wall (O(N*M) method), we should instead be getting the wall-list from the SpatialPartition table (Done sometime...)

*/
